package com.yuexunit.operationman.nbsy.module.SurgicalReceipt.ui.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.yuexunit.operationman.nbsy.R;
import com.yuexunit.operationman.nbsy.config.AppConfig;
import com.yuexunit.operationman.nbsy.module.SurgicalReceipt.Bean.SurgicalReceiptBean;
import com.yuexunit.operationman.nbsy.module.SurgicalReceipt.ui.Act_SurgicalReceipt_Preview;

import org.kymjs.kjframe.ui.KJFragment;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by chenss on 2017/7/27 0027.
 */

public class Fragment_SR_Ward extends KJFragment {

    @Bind(R.id.frag_sr_w01)
    TextView fragSrW01;
    @Bind(R.id.frag_sr_w02)
    TextView fragSrW02;
    @Bind(R.id.frag_sr_w03)
    TextView fragSrW03;
    @Bind(R.id.frag_sr_w04)
    TextView fragSrW04;
    @Bind(R.id.frag_sr_w05)
    TextView fragSrW05;
    @Bind(R.id.frag_sr_w06)
    TextView fragSrW06;
    @Bind(R.id.frag_sr_w07)
    TextView fragSrW07;
    @Bind(R.id.frag_sr_w08)
    TextView fragSrW08;
    @Bind(R.id.frag_sr_w09)
    TextView fragSrW09;
    @Bind(R.id.frag_sr_w10)
    TextView fragSrW10;
    @Bind(R.id.frag_sr_w11)
    TextView fragSrW11;
    @Bind(R.id.frag_sr_w12)
    TextView fragSrW12;
    @Bind(R.id.frag_sr_w13)
    TextView fragSrW13;
    @Bind(R.id.frag_sr_w14)
    TextView fragSrW14;
    @Bind(R.id.frag_sr_w15)
    TextView fragSrW15;
    @Bind(R.id.frag_sr_w16)
    TextView fragSrW16;
    @Bind(R.id.frag_sr_w17)
    TextView fragSrW17;
    @Bind(R.id.frag_sr_w18)
    TextView fragSrW18;
    @Bind(R.id.frag_sr_w19)
    TextView fragSrW19;
    @Bind(R.id.frag_sr_w20)
    TextView fragSrW20;
    @Bind(R.id.frag_sr_w21)
    TextView fragSrW21;
    @Bind(R.id.frag_sr_w22)
    TextView fragSrW22;
    @Bind(R.id.frag_sr_w23)
    TextView fragSrW23;
    @Bind(R.id.frag_sr_w24)
    TextView fragSrW24;
    @Bind(R.id.frag_sr_w25)
    TextView fragSrW25;

    private Act_SurgicalReceipt_Preview aty;
    protected View mMainView;

    @Override
    protected View inflaterView(LayoutInflater inflater, ViewGroup container, Bundle bundle) {
        aty = (Act_SurgicalReceipt_Preview) getActivity();
        mMainView = inflater.inflate(R.layout.fragment_sr_ward, container, false);
        ButterKnife.bind(this, mMainView);
        return mMainView;
    }

    @Override
    protected void initData() {
        for (SurgicalReceiptBean.ObjectEntity.HandoverItemListEntity p : AppConfig.SURGICALRECEIPTBEAN.getObject().getHandoverItemList()) {
            switch (p.getItemCode()) {
                case "BS_First":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrW01.setText("是");
                        } else {
                            fragSrW01.setText("否");
                        }
                        if (skin[1].equals("1")) {
                            fragSrW02.setText("是");
                        } else {
                            fragSrW02.setText("否");
                        }
                        if (skin[2].equals("1")) {
                            fragSrW03.setText("是");
                        } else {
                            fragSrW03.setText("否");
                        }
                        if (skin[3].equals("1")) {
                            fragSrW04.setText("是");
                        } else {
                            fragSrW04.setText("否");
                        }
                        if (skin[4].equals("1")) {
                            fragSrW05.setText("是");
                        } else {
                            fragSrW05.setText("否");
                        }
                        if (skin[5].equals("1")) {
                            fragSrW06.setText("是");
                        } else {
                            fragSrW06.setText("否");
                        }
                        if (skin[6].equals("1")) {
                            fragSrW07.setText("是");
                        } else {
                            fragSrW07.setText("否");
                        }
                        if (skin[7].equals("1")) {
                            fragSrW08.setText("是");
                        } else {
                            fragSrW08.setText("否");
                        }
                    }
                    break;
                case "BS_ShiWuQueRen":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrW09.setText("是" + "\n" + skin[2]);
                        }
                        if (skin[1].equals("1")) {
                            fragSrW09.setText("否");
                        }
                    }
                    break;
                case "BS_DaiRuWuPin":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_bs_01);
                        if (skin[0].equals("1")) {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[0];
                            } else {
                                content += arrays[0];
                            }
                        }
                        if (skin[1].equals("1")) {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[1];
                            } else {
                                content += arrays[1];
                            }
                        }
                        if (skin[2].equals("1")) {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[2];
                            } else {
                                content += arrays[2];
                            }
                        }
                        if (skin[3].equals("1")) {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[3] + ":" + skin[5] + "张";
                            } else {
                                content += arrays[3] + ":" + skin[5] + "张";
                            }
                        }
                        if (skin[4].equals("1")) {
                            if (content.length() > 0) {
                                content += "\n";
                                content += arrays[4] + ":" + p.getItemOther();
                            } else {
                                content += arrays[4] + ":" + p.getItemOther();
                            }
                        }

                        fragSrW10.setText(content);
                    }
                    break;
                case "BS_ShenFenQueRen":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrW11.setText("是");
                        } else {
                            fragSrW11.setText("否");
                        }
                    }
                    break;
                case "BS_YiShi":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_bs_02);
                        if (skin[0].equals("1")) {
                            fragSrW12.setText(arrays[0]);
                        }
                        if (skin[1].equals("1")) {
                            fragSrW12.setText(arrays[1]);
                        }
                        if (skin[2].equals("1")) {
                            fragSrW12.setText(arrays[2]);
                        }
                        if (skin[3].equals("1")) {
                            fragSrW12.setText(arrays[3]);
                        }
                        if (skin[4].equals("1")) {
                            fragSrW12.setText(arrays[4]);
                        }
                    }
                    break;
                case "BS_T":
                    if (p.getItemOther().length() > 0) {
                        fragSrW13.setText(p.getItemOther());
                    }
                    break;
                case "BS_P":
                    if (p.getItemOther().length() > 0) {
                        fragSrW14.setText(p.getItemOther());
                    }
                    break;
                case "BS_R":
                    if (p.getItemOther().length() > 0) {
                        fragSrW15.setText(p.getItemOther());
                    }
                    break;
                case "BS_BP":
                    if (p.getItemOther().length() > 0) {
                        fragSrW16.setText(p.getItemOther());
                    }
                    break;
                case "BS_YaChuang":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrW17.setText("无");
                        }
                        if (skin[1].equals("1")) {
                            fragSrW17.setText("有" + "\n" + skin[2] + "\n" + skin[3]);
                        }
                    }
                    break;
                case "BS_XueZhiPin":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        if (skin[0].equals("1")) {
                            fragSrW18.setText("无");
                        }
                        if (skin[1].equals("1")) {
                            fragSrW18.setText("有");
                        }
                    }
                    break;
                case "BS_Guandao":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String content = "";
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_bs_04);
                        if (skin[0].equals("1")) {
                            content += "无";
                        }
                        if (skin[1].equals("1")) {
                            content += "有";
                            if (skin[2].equals("1")) {
                                content += "\n";
                                content += arrays[0] + "长度" + skin[11] + "cm";
                            }
                            if (skin[3].equals("1")) {
                                content += "\n";
                                content += arrays[1];
                            }
                            if (skin[4].equals("1")) {
                                content += "\n";
                                content += arrays[2];
                            }
                            if (skin[5].equals("1")) {
                                content += "\n";
                                content += arrays[3];
                            }
                            if (skin[6].equals("1")) {
                                content += "\n";
                                content += arrays[4];
                            }
                            if (skin[7].equals("1")) {
                                content += "\n";
                                content += arrays[5] + "数量" + skin[12] + "根";
                            }
                            if (skin[8].equals("1")) {
                                content += "\n";
                                content += arrays[6];
                            }
                            if (skin[9].equals("1")) {
                                content += "\n";
                                content += arrays[7];
                            }
                            if (skin[10].equals("1")) {
                                content += "\n";
                                content += arrays[8];
                            }
                        }

                        if (p.getItemOther().length() > 0) {
                            content += "\n";
                            content += "其他:" + p.getItemOther();
                        }
                        fragSrW19.setText(content);
                    }
                    break;
                case "BS_XiYangFangShi":
                    if (p.getItemValue().length() > 0) {
                        String[] skin = p.getItemValue().split(";", -1);
                        String[] arrays = getResources().getStringArray(R.array.surgicalreceipt_bs_03);
                        if (skin[0].equals("1")) {
                            fragSrW20.setText(arrays[0]);
                        }
                        if (skin[1].equals("1")) {
                            fragSrW20.setText(arrays[1]);
                        }
                        if (skin[2].equals("1")) {
                            fragSrW20.setText(arrays[2]);
                        }
                        if (skin[3].equals("1")) {
                            fragSrW20.setText(arrays[3]);
                        }
                        if (skin[4].equals("1")) {
                            fragSrW20.setText(arrays[4]);
                        }
                        if (skin[5].equals("1")) {
                            fragSrW20.setText(arrays[5]);
                        }
                        if (skin[6].equals("1")) {
                            fragSrW20.setText(arrays[6]);
                        }
                    }
                    break;
                case "BS_Other":
                    if (p.getItemOther().length() > 0) {
                        fragSrW21.setText(p.getItemOther());
                    }
                    break;
            }
        }
        if (AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getBsWardNurseUrl() != null) {
            fragSrW22.setText(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getBsWardNurse());
            fragSrW23.setText(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getBsWardNurseTimeStr());
        }
        if (AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getBsOrNurseUrl() != null) {
            fragSrW24.setText(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getBsOrNurse());
            fragSrW25.setText(AppConfig.SURGICALRECEIPTBEAN.getObject().getTransferHandover().getBsOrNurseTimeStr());
        }
    }

}
